/**
 * 
 */
package com.net.shop.car.manager.ui.guaguale;

import java.util.ArrayList;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Gallery;
import android.widget.ImageView;

import com.net.shop.car.manager.BaseFragment;
import com.net.shop.car.manager.R;
import com.net.shop.car.manager.ui.adapter.GuaGuaLeAdapter;
import com.net.shop.car.manager.ui.view.GuaGuaLeGallery;

/**
 * 车附近
 * 
 * @author Deve
 * 
 */
public class GuagualeFragment extends BaseFragment {
	  float i;
	  float j;
	ArrayList<ImageView> list;
	/**
	 * 
	 */
	public GuagualeFragment() {

	}

	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_guaguale,
				container, false);
		initViews(view);
		getWindow();
		return view;

	}
	public void getWindow(){
		 i=holder.getResources().getDisplayMetrics().xdpi;
		 j=holder.getResources().getDisplayMetrics().ydpi;
		 System.out.println("===================="+holder.getResources().getDisplayMetrics().heightPixels+"============================="+holder.getResources().getDisplayMetrics().widthPixels);
		 System.out.println("打印屏幕像素X                 "+PxUtil.dip2px(holder, i));
		 System.out.println("打印屏幕像素Y                 "+PxUtil.dip2px(holder,j));
		 System.out.println("-----------------------------------------------------------------------");
	}
	@SuppressWarnings("deprecation")
	private void initViews(View view) {
		list=new ArrayList<ImageView>();
		for(int i=0;i<8;i++){
			ImageView img=new ImageView(holder);
			img.setImageResource(R.drawable.x);
			list.add(img);
		}
		 final GuaGuaLeGallery gallery =(GuaGuaLeGallery)view.findViewById(R.id.guagua);
		 
	      GuaGuaLeAdapter adapter = new GuaGuaLeAdapter(this.holder,list);
	        adapter.createReflectedImages();
	      /*  gallery.setOnItemSelectedListener(new OnItemSelectedListener() {

				@Override
				public void onItemSelected(AdapterView<?> parent, View view,
						int position, long arg3) {
					 ImageView imageview = (ImageView)view;
				  imageview.setImageDrawable(list.get(position).getDrawable());

					for(int i=0; i<parent.getChildCount();i++){
						             //缩小选中图片旁边的图片
						 view.setLayoutParams(new LayoutParams(500, 600));

						       ImageView local_imageview = (ImageView)parent.getChildAt(i);
					          if(local_imageview!=imageview){
						              local_imageview.setLayoutParams(new GuaGuaLeGallery.LayoutParams(520/4, 318/4));
						                local_imageview.setScaleType(ImageView.ScaleType.FIT_CENTER);
						            }
						        }
				}

				@Override
				public void onNothingSelected(AdapterView<?> arg0) {
					
				}
			});*/

	        gallery.setAdapter(adapter);
	}

}
